#pragma once

#include "IntervalConstraint.h"

#include "Interval.h"

namespace uml {

IntervalConstraint::IntervalConstraint(const QString& umlType)
    : Constraint(umlType) {}

void IntervalConstraint::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    Constraint::fromJson(json, errorList);
    specification_ = JsonSerializable::create<Interval>(json.value("specification"), errorList);

}

void IntervalConstraint::toJson(QJsonObject& json) {
    Constraint::toJson(json);
    if (specification_) {
        QJsonObject specification_json;
        specification_->toJson(specification_json);
        json.insert("specification", specification_json);
    }
}

/// <summary>
/// specification getter
/// The Interval that specifies the condition of the IntervalConstraint.
/// </summary>
shared_ptr<Interval> IntervalConstraint::specification() const {
    return specification_;
}

/// <summary>
/// specification setter
/// The Interval that specifies the condition of the IntervalConstraint.
/// </summary>
void IntervalConstraint::setSpecification(shared_ptr<Interval> value) {
    specification_ = value;
}

} // namespace uml
